package com.xiaoma.bingox.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dexcoder.commons.pager.Pager;
import com.dexcoder.dal.JdbcDao;
import com.dexcoder.dal.spring.page.PageControl;
import com.xiaoma.bingox.entity.Test1;

@Service
public class TestDalService {

    @Autowired
    private JdbcDao jdbcDao;
    
    public List<Test1> findAll() {
        return jdbcDao.queryList(Test1.class);
    }
    
    public void save(Test1 test) {
        jdbcDao.save(test);
    }
    
    public void update(Test1 test) {
        jdbcDao.update(test);
    }
    
    public void delete (int id) {
        jdbcDao.delete(Test1.class, id);
    }
    
    public List<Test1> page(int curPage, int perPage) {
        PageControl.performPage(curPage, perPage);
        jdbcDao.queryList(Test1.class);
        Pager pager = PageControl.getPager();
        List<Test1> t1s = pager.getList(Test1.class);
        for (Test1 item : t1s) {
            System.out.println(item.getName() + item.getAge());
        }
        System.out.println(pager.getItemsTotal());
        return t1s;
    }
}
